<template>
	<view class="container">
		<TopBtn :title="'我的团队'"></TopBtn>
		<view class="listTitle">
			我创建的团队
		</view>
		<view class="listBox">
			<view class="list" v-if="teamManageRespVO">
				<view class="" @click="goinfo(teamManageRespVO.doctorId)">
					<view class="title flex-center">
						<image :src="teamManageRespVO.avatar" mode=""></image>
						<view class="name flex1">
							<view class="nameinfo flex-sp-center">
								<view class="nameText flex-sp-center">
									<image src="@/static/my/wdtd.png" mode=""></image> {{teamManageRespVO.doctorName}}的团队
								</view>
								<view class="">
									共{{teamManageRespVO.teamNum}}人
								</view>
							</view>
							<view class="btmBox flex-sp-center">
								<view class="">
									<uni-icons type="calendar" color="#999" size="16"></uni-icons>
									<uni-dateformat :date="teamManageRespVO.createTime" format="yyyy-MM-dd hh:mm"></uni-dateformat>
								</view>
								<view class="del flex-center">
									管理
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="" v-else>
				<view class="btn flex-center-center" @click="goAdd()">
					邀请成员
				</view>
			</view>
		</view>
		<view class="listTitle">
			我加入的团队
		</view>
		<view class="listBox">
			<view class="list" v-for="n in list" :key="n.id" @click="goinfo(n.doctorId)">
				<view class="">
					<view class="title flex-center">
						<image :src="n.avatar" mode=""></image>
						<view class="name flex1">
							<view class="nameinfo flex-sp-center">
								{{n.doctorName}}的团队
								<view class="">
									共{{n.teamNum}}人
								</view>
							</view>
							<view class="btmBox flex-sp-center">
								<view class="">
									<uni-icons type="calendar" color="#999" size="16"></uni-icons>
									<uni-dateformat :date="n.createTime" format="yyyy-MM-dd hh:mm"></uni-dateformat>
								</view>
								<view class="del flex-center">
									查看
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="kong">

		</view>
	</view>
</template>

<script>
	import {
		getMyTeamManage,
	} from '@/api/user'
	export default {
		data() {
			return {
				act: "1",
				list: [],
				request: {
					pageNo: 1,
					pageSize: 10,
				},
				maxNum: "",
				teamManageRespVO: {}

			};
		},
		onShow() {
			this.list = []
			this.getMyTeamManage()
		},
		onReachBottom() {
			if (this.maxNum <= this.request.pageNo) return
			this.request.pageNo = this.request.pageNo + 1
			this.getMyTeamManage()
		},
		methods: {
			getMyTeamManage() {
				getMyTeamManage(this.request).then(res => {
					this.list.push(...res.data.pageResult.list)
					this.teamManageRespVO = res.data.teamManageRespVO
					let num = res.data.pageResult.total / this.request.pageSize
					if (num.toString().includes('.')) {
						num = Math.ceil(num)
					}
					this.maxNum = num
				})
			},
			goAdd() {
				uni.navigateTo({
					url: `/pages/ConsultationRoom/SelectPersonnel/SelectPersonnel?type=team`,
				})
			},
			goinfo(id) {
				if (id) {
					uni.navigateTo({
						url: `/pages/my/MyTeam/MyTeam?id=${id}`,
					})
				}
			},
		}
	}
</script>

<style lang="less" scoped>
	.btn {
		width: 649rpx;
		height: 100rpx;
		background: #3B6CFE;
		border-radius: 50rpx;
		font-weight: 500;
		font-size: 28rpx;
		color: #FFFFFF;
	}

	.listTitle {
		height: 90rpx;
		line-height: 90rpx;
		font-weight: bold;
		font-size: 32rpx;
		color: #999999;
		margin-left: 30rpx;
	}

	.listBox {
		padding: 0 30rpx;

		.flex1 {
			flex: 1;
		}

		.list {
			width: 690rpx;
			min-height: 182rpx;
			background: #FFFFFF;
			border-radius: 30rpx;
			padding: 20rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-around;
			margin-bottom: 30rpx;

			&>view {
				flex: 1;
			}

			.btmBox {
				margin-top: 25rpx;
				font-weight: 500;
				font-size: 26rpx;
				color: #999999;

				.del {
					color: #3B6CFE;
				}

				image {
					width: 31rpx;
					height: 29rpx;
					margin-right: 10rpx;
				}
			}

			.title {
				.name {
					font-weight: bold;
					font-size: 32rpx;
					color: #333333;

					.nameinfo {
						.nameText {
							font-weight: bold;
							font-size: 32rpx;
							color: #333333;

						}

						view {
							font-weight: 500;
							font-size: 24rpx;
							color: #999999;
						}

						image {
							width: 24rpx;
							height: 27rpx;
							margin-right: 10rpx;
						}
					}

					text {
						font-weight: 500;
						font-size: 26rpx;
						color: #999;
						// margin-left: 19rpx;
					}
				}

				&>image {
					width: 90rpx;
					height: 90rpx;
					margin-right: 30rpx;
					border-radius: 50%;
				}
			}

			.text {
				font-weight: 500;
				font-size: 26rpx;
				color: #333333;
				margin-top: 30rpx;
				padding-bottom: 30rpx;
				border-bottom: 1rpx solid #eee;

				text {
					color: #999;
				}
			}

			.typeBox {
				margin-top: 15rpx;
				font-weight: 500;
				font-size: 26rpx;
				color: #666666;

				text {
					display: inline-block;
					width: 63rpx;
					height: 33rpx;
					background: #DEF7ED;
					border-radius: 10rpx;
					font-weight: 500;
					font-size: 22rpx;
					color: #23CC88;
					text-align: center;
					line-height: 33rpx;
					margin-right: 10rpx;
				}

			}


		}
	}
</style>